package cn.sinjet.phone;

import cn.sinjet.utils.ChineseToEnglish;

public class Contact {
   private String name;
   private String number;
   private String group;
//   private String lookupKey;
   private String jianpinNumber;
   private String quanpinNumber;
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
		String firstLetters = ChineseToEnglish.getPinYinFirstLetters(name).toLowerCase();//UnicodeGBK2Alpha.getSimpleCharsOfString(name);
		this.jianpinNumber = strTo9Number(firstLetters);
		String pinyin = ChineseToEnglish.getPingYin(name).toLowerCase();
		this.quanpinNumber = strTo9Number(pinyin);
//		Log.i("phone", "jian pin:"+firstLetters+" ="+jianpinNumber+
//				"   quanpin:"+pinyin+" ="+quanpinNumber);
	}
	public String getNumber() {
		return number;
	}
	public void setNumber(String number) {
		this.number = number;
	}
	public String getGroup() {
		return group;
	}
	public void setGroup(String group) {
		this.group = group;
	}
	/*public void setDesplayName(String name2) {
		// TODO Auto-generated method stub
		
	}
	public void setPhoneNum(String number2) {
		// TODO Auto-generated method stub
		
	}*/
	public void setSortKey(String sortKey) {
		// TODO Auto-generated method stub
		
	}
	public void setPhotoId(Long photoId) {
		// TODO Auto-generated method stub
		
	}
	public void setLookUpKey(String lookUpKey) {
		// TODO Auto-generated method stub
//		this.lookupKey = lookUpKey;
	}
	public String getJianpinNumber() {
		return jianpinNumber;
	}
	public void setJianpinNumber(String jianpinNumber) {
		this.jianpinNumber = jianpinNumber;
	}
	public String getQuanpinNumber() {
		return quanpinNumber;
	}
	public void setQuanpinNumber(String quanpinNumber) {
		this.quanpinNumber = quanpinNumber;
	}
	public static String strTo9Number(String string){
//		String result = "";
		StringBuilder sb = new StringBuilder();
		for(int i=0;i<string.length();i++){
			char c = string.charAt(i);
			switch(c){
			case 'a': case 'b': case 'c':
				sb.append("2");
				break;
			case 'd': case 'e': case 'f':
				sb.append("3");
				break;
			case 'g': case 'h': case 'i':
				sb.append("4");
				break;
			case 'j': case 'k': case 'l':
				sb.append("5");
				break;
			case 'm': case 'n': case 'o':
				sb.append("6");
				break;
			case 'p': case 'q': case 'r': case 's':
				sb.append("7");
				break;
			case 't': case 'u': case 'v':
				sb.append("8");
				break;
			case 'w': case 'x': case 'y': case 'z':
				sb.append("9");
				break;
			}
		}
		return sb.toString();
	}
}
